﻿// Poly_test.cpp: 定义应用程序的入口点。
//

#include "Poly_test.h"
#include <iostream>
using namespace std;
class People {
public:
	People(char* name, int age);
	virtual void show(); // 派生类就不用加virtual ,基类加了就不会出现 命名冲突
protected:
	char* m_name;
	int  m_age;
};

People::People(char* name, int age) :m_name(name), m_age(age) {}
void People::show()
{
	cout << "大家好我叫" << m_name << "今年" << m_age << "了" << endl;
}

class Student :public People {
public:
	Student(char* name, int age, int salary);
	void show();
protected:
	int m_salary;
};

Student::Student(char* name, int age, int salary) : People(name, age), m_salary(salary) { }

void Student::show()
{
	cout << m_name << "今年" << m_age << "岁了，月收入" << m_salary << endl;
}


int main()
{
	Student* s1 = new Student("wang",45,5000);
	s1->show();

	People * s2 = new People("xiaoming", 15);
	s2->show();

	s1 = new Student("wang", 45, 5000);
	s1->show();

	return 0;
}